using System;

namespace Lt.Workflow
{
    public class ContextBasedAction<TContext> : WorkflowItem
        where TContext : class 
    {
        private readonly Action<TContext> customAction;

        public ContextBasedAction(Action<TContext> customAction)
        {
            this.customAction = customAction;
        }

        public override void Run(params object[] args)
        {
            this.customAction((TContext)args[0]);
        }

        public override bool Validate(bool throwException = false)
        {
            return customAction != null;
        }
    }
}